package peer.p2pnet;

import java.util.HashMap;

import peer.ThreadCounter;
import peer.share.BlockInfo;
import peer.tools.Mdb;

public class PubThread_ReRegAssist implements Runnable{
	Mdb mdb;
	Thread t;
	CastPubThread ct;
	public boolean run=true;
	BlockInfo bi;
	public PubThread_ReRegAssist(Mdb mdb,BlockInfo bi){
		this.mdb=mdb;
		this.bi=bi;
		t=new Thread(this);
		t.start();
	}
	
	public void stopAddThread(){
		run=false;
		t.interrupt();
		if(ct!=null){
			ct.stopCast();
		}
	}
	
	@SuppressWarnings("unchecked")
	public void run() {
		
		String tstr="gj568iouiokuiol";
		peer.ThreadCounter tc;
		if(!peer.Core.ThreadStrTable.containsKey(tstr)){
			tc=new peer.ThreadCounter();
			peer.Core.ThreadStrTable.put(tstr, tc);
		}
		tc=(ThreadCounter) peer.Core.ThreadStrTable.get(tstr);
		tc.conut++;
		
		HashMap dbBNodeList=peer.NetTools.loadDBNodeList(mdb,false);
		if(dbBNodeList!=null){
			if(dbBNodeList.size()!=0){
				ct=new CastPubThread(mdb,dbBNodeList,bi);
			}
		}
	
		tc.conut--;
	}

}
